package com.asset.inventory.base

import android.os.Bundle
import android.util.Log
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel


/**
 *    @author : sibb
 *    date   : 21-3-16
 *    desc   : viewModel基类
 */
open class BaseViewModel: ViewModel(),IBaseViewModel {

    val clazzLiveData = MutableLiveData<ClassLoader>()

    val toastStr = MutableLiveData<String>()

    val toastResId = MutableLiveData<Int>()

    companion object {
        private const val TAG = "BaseViewModel"
    }

    override fun onAny(owner: LifecycleOwner, event: Lifecycle.Event) {
        Log.d(Companion.TAG,"onAny")
    }

    override fun onCreate() {
        Log.d(Companion.TAG,"onCreate")
    }

    override fun onDestory() {
        Log.d(Companion.TAG,"onDestory")
        onCleared()
    }

    override fun onStart() {
        Log.d(Companion.TAG,"onStart")
    }

    override fun onStop() {
        Log.d(Companion.TAG,"onStop")
    }

    override fun onResume() {
        Log.d(Companion.TAG,"onResume")
    }

    override fun onPause() {
        Log.d(Companion.TAG,"onPause")
    }

    protected fun showToast(str: String){
        toastStr.postValue(str)
    }

    protected fun showToast(resId: Int){
        toastResId.postValue(resId)
    }





}